Skip to content

fix(db): raise db pool size#4263

Merged
TheodoreSpeaks merged 3 commits intostagingfrom
fix/raise-db-connections
Apr 22, 2026
Merged

fix(db): raise db pool size#4263
TheodoreSpeaks merged 3 commits intostagingfrom
fix/raise-db-connections

Conversation

@TheodoreSpeaks
Copy link
Copy Markdown
Collaborator

Summary

Previously we decreased our max db connections per task. This caused issues scaling when we were hit with a sudden spike in network requests. With transaction mode pgbouncer we can afford to have higher numbers here.
Fixes #(issue)

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Other: ___________

Testing

  • Config change, no testing

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Screenshots/Videos

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 22, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment Apr 22, 2026 6:16pm

Request Review

@cursor
Copy link
Copy Markdown

cursor Bot commented Apr 22, 2026

PR Summary

Medium Risk
Changes database connection pooling limits, which can affect runtime stability and database/pgbouncer capacity under load. Low code risk but higher operational risk if connection limits are mis-sized.

Overview
Raises the Postgres client pool limit (max) from 10 → 30 in both the socket DB operations client (apps/sim/socket/database/operations.ts) and the shared DB package (packages/db/index.ts) to allow more concurrent DB usage during traffic spikes.

Reviewed by Cursor Bugbot for commit 94e0e62. Bugbot is set up for automated code reviews on this repo. Configure here.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 22, 2026

Greptile Summary

This PR increases the postgres.js connection pool max for the main DB client (packages/db/index.ts: 10 → 20) and the socket-specific client (apps/sim/socket/database/operations.ts: 10 → 25) to address connection exhaustion under request spikes. Because PgBouncer runs in transaction mode, these are client-side limits that PgBouncer multiplexes before hitting the server, so the change is safe.

Confidence Score: 5/5

Safe to merge — config-only change with no logic impact and a well-understood rationale (PgBouncer transaction mode).

Both changes are single-value config bumps with no code logic affected. The asymmetry (20 vs 25) appears intentional given the socket server's higher per-instance concurrency requirements. No P0/P1 findings.

No files require special attention.

Important Files Changed

Filename Overview
packages/db/index.ts Raises the postgres.js connection pool max from 10 → 20 for the main database client used across the app.
apps/sim/socket/database/operations.ts Raises the socket-specific connection pool max from 10 → 25; no logic changes.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[App Instances] -->|"max: 20 connections each"| B[PgBouncer\nTransaction Mode]
    C[Socket Server] -->|"max: 25 connections each"| B
    B -->|"Multiplexed server connections"| D[(PostgreSQL)]
    style B fill:#f0a500,color:#000
    style D fill:#336791,color:#fff
Loading

Reviews (1): Last reviewed commit: "Raise socket connections" | Re-trigger Greptile

@TheodoreSpeaks TheodoreSpeaks merged commit d927d8b into staging Apr 22, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant